Skip to content

Conversation

@marle3003
Copy link
Owner

Potential fix for https://github.com/marle3003/mokapi/security/code-scanning/54

To fix the problem:

  • Replace any use of strconv.Atoi (which returns an architecture-dependent int) with strconv.ParseInt specifying the expected bit size, such as 32 for int32, and use this bit size in all relevant conversions.
  • Ensure that wherever conversion to a smaller integer type such as int32 is performed, the parsing and/or conversion step is constrained so that overflow can not occur, either by parsing directly to a bounded type, or by explicit bounds checks before conversion.
  • In providers/openapi/schema/parse_xml.go at line 170, replace strconv.Atoi(s) with strconv.ParseInt(s, 10, 32) so that large out-of-range values will fail, and return an int32.
  • In schema/json/parser/parser_integer.go, for case "int32", replace strconv.Atoi(v) with strconv.ParseInt(v, 10, 32) and use its result. This will ensure the parsed value will not exceed the int32 range.

No additional packages or external dependencies are needed, just changes to use strconv.ParseInt and direct conversion to int32 from its result.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

marle3003 and others added 2 commits December 13, 2025 17:01
…tween integer types

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Dec 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.86%. Comparing base (cf32e10) to head (5bfbeb7).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #780      +/-   ##
==========================================
- Coverage   70.86%   70.86%   -0.01%     
==========================================
  Files         457      457              
  Lines       41293    41293              
==========================================
- Hits        29264    29262       -2     
- Misses       9865     9866       +1     
- Partials     2164     2165       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marle3003 marle3003 marked this pull request as ready for review December 13, 2025 23:05
@marle3003 marle3003 merged commit 6c1a191 into main Dec 13, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants